﻿using NUnit.Framework;

namespace Cumulux.BootStrapper.Tests
{
    [TestFixture]
    public class AzureArgumentsParserTest
    {
        
        [Test]
        public void ParseLocalResource()
        {
            AzureArgumentsParser parser = new AzureArgumentsParser();
            var parsed = parser.ParseArguments(@"$lr(temp)\somefile.txt");

            Assert.AreEqual(@"C:\Resources\Temp\somefile.txt", parsed);
        }

        [Test]
        public void ParseStorageConnection()
        {
            AzureArgumentsParser parser = new AzureArgumentsParser();
            var parsed = parser.ParseArguments(@"$sc(DefaultConnectionString)");

            Assert.AreEqual(@"DefaultEndpointsProtocol=https;AccountName=poopypants;AccountKey=jnF1630y1w==", parsed);
        }

        [Test]
        public void ParseMultiplePrefixes()
        {
            var parser = new AzureArgumentsParser();
            var actual = parser.ParseArguments(@"-lr $lr(temp) -run $lr(temp)\file.exe");

            Assert.AreEqual(@"-lr C:\Resources\Temp -run C:\Resources\Temp\file.exe", actual);
        }

        [Test]
        public void DoNotExpandUnknownPrefixes()
        {
            var parser = new AzureArgumentsParser();
            var actual = parser.ParseArguments(@"-switch $tdd(cumulux)");

            Assert.AreEqual(@"-switch $tdd(cumulux)", actual);
        }

        [Test]
        public void ParseConfig()
        {
            var parser = new AzureArgumentsParser();
            var actual = parser.ParseArguments(@"$config(foo.installContainer)");
            var expected = "container";

            Assert.AreEqual(expected, actual);
        }

    }
}
